package com.adun.scheduler.controller;

import com.adun.scheduler.SchedulerJobManager;
import com.adun.scheduler.common.AmisResult;
import com.adun.scheduler.vo.SchedulerJobVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 定时任务job控制器
 *
 * @author ZDF
 * @date 2025/8/8
 */
@RestController
@RequestMapping("/dynamic/scheduler/job")
public class SchedulerJobController {
    @GetMapping("/list")
    public AmisResult<List<SchedulerJobVo>> list() {
        List<SchedulerJobVo> schedulerJobVos = SchedulerJobManager.getSchedulerJobVos();
        return AmisResult.success(schedulerJobVos);
    }

    @GetMapping("/xxl-job/executor/init-sql")
    public AmisResult<String> xxlJobExecutorInitSql() {
        String xxlJobExecutorInitSQL = SchedulerJobManager.getXxlJobExecutorInitSQL();
        return AmisResult.success(xxlJobExecutorInitSQL);
    }

    @GetMapping("/xxl-job/task/init-sql")
    public AmisResult<List<String>> xxlJobTaskInitSQL() {
        List<String> xxlJobTaskInitSQLList = SchedulerJobManager.getXxlJobTaskInitSQL();
        return AmisResult.success(xxlJobTaskInitSQLList);
    }
}
